// we need to add the ejb3-ejb project to the library of the project,
//otherwise we can not work with the classes
//!!!!!!!!!!!!!!
//com.sun.enterprise.naming.SerialInitContextFactory is in appserv-rt.jar of glassfish
//com.sun.logging.LogDomains is in appserv-deployment-client.jar
//com/sun/appserv/management/util/misc/RunnableBase is in appserv-ext.jar
//javax/security/jacc/PolicyContextException is in javaee.jar
//!!!!!!!!!!!!!!!!!!!!!!!!!
package javafx_20092010_reeks2.persistence;

import be.khleuven.screencasting.Facades.QueryFacadeRemote;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

public class Fx_EJB_Entry_Point {

    public Fx_EJB_Entry_Point(){
        
    }

    public QueryFacadeRemote lookUpQueryFacade() {
        try {
            Properties props = new Properties();
            props.setProperty("java.naming.factory.initial",
                    "com.sun.enterprise.naming.SerialInitContextFactory");
            props.setProperty("java.naming.factory.url.pkgs",
                    "com.sun.enterprise.naming");
            props.setProperty("java.naming.factory.state",
                    "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
            props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
            props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
            Context c = new InitialContext(props);
            return (QueryFacadeRemote) c.lookup("be.khleuven.screencasting.Facades.QueryFacadeRemote");
        } catch (NamingException ne) {
            System.out.println("exception caught" + ne);
            throw new RuntimeException(ne);
        }
    }
}
